package com.awn.weidian.demo.controller;

import java.util.List;

import com.awn.weidian.demo.mapper.IOrderOfGoods;
import com.awn.weidian.demo.pojo.OrderOfGoods;
import com.awn.weidian.demo.service.DateHandle;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController//返回json的内容到页面 是controller和restbody的合集
@CrossOrigin//实现跨域
@RequestMapping("/api/")//映射地址 

public class OrderOfGoodsController{

	@Autowired//引入其他包
    IOrderOfGoods pm;

    @Autowired
    DateHandle dh;
    

    @PostMapping("/addorder")
    public int addorder(@RequestBody OrderOfGoods oog){
        oog.setOid(dh.createOrder());
        oog.setOrdertime(dh.showTime());
        return pm.addOrder(oog);
    }
    /**
     * @GetMapping() Restful协议中针对查询,提供的访问服务
     */
    @GetMapping("/showoog")
    public List<OrderOfGoods> showOrder(){
        return pm.showOrder();
    }
    
    @PostMapping("/updatepayment")
    public int updatePayment(@RequestBody OrderOfGoods oog){
        return pm.updatePayment(oog);
    }

    @PostMapping("/updaterefund")
    public int updateRefund(@RequestBody OrderOfGoods oog){
        return pm.updateRefund(oog);
    }

    @PostMapping("/updaterefunded")
    public int updateRefunded(@RequestBody OrderOfGoods oog){
        return pm.updateRefunded(oog);
    }

    @PostMapping("/updatereclose")
    public int updatereClose(@RequestBody OrderOfGoods oog){
        return pm.updatereClose(oog);
    }
    
    @PostMapping("/updatedeliver")
    public int updateDeliver(@RequestBody OrderOfGoods oog){
        return pm.updateDeliver(oog);
    }
    
    @PostMapping("/updatecollect")
    public int updateCollect(@RequestBody OrderOfGoods oog){
        return pm.updateCollect(oog);
    }

    @PostMapping("/updateorderstate")
    public int updateOrderstate(@RequestBody OrderOfGoods oog){
        return pm.updateOrderstate(oog);
    }

    @PostMapping("/updatebuyerevaluate")
    public int updateBuyerevaluate(@RequestBody OrderOfGoods oog){
        return pm.updateBuyerevaluate(oog);
    }

    @PostMapping("/updatesellerevaluate")
    public int updateSellerevaluate(@RequestBody OrderOfGoods oog){
        return pm.updateSellerevaluate(oog);
    }

}